{template 'header'}
<link href="./resource/css/app.css" rel="stylesheet">
<ul class="nav nav-tabs">
    <li class="active"><a href="{php echo $this->createWeburl('member');}">用户管理</a></li>
    <li class=""><a href="{php echo $this->createWebUrl('fictitious')}">虚拟用户管理</a></li>
</ul>
<form action="./index.php" method="get" class="form-horizontal">
    <input type="hidden" name="c" value="site">
    <input type="hidden" name="a" value="entry">
    <input type="hidden" name="m" value="bh_bargain">
    <input type="hidden" name="do" value="member">
    <div class="form-group">
        <label class="col-xs-12 col-sm-1 control-label">用户昵称</label>
        <div class="col-sm-1 col-xs-12">
            <input type="text" class="form-control" name="nickname"  value="{$nickname}" />
        </div>
        <label class="col-xs-12 col-sm-1 control-label">用户id</label>
        <div class="col-sm-1 col-xs-12">
            <input type="text" class="form-control" name="member_id"  value="{$member_id}" />
        </div>
        <label class="col-xs-12 col-sm-1 control-label">用户类型</label>
        <div class="col-sm-1 col-xs-12">
            <select name="is_fictitious">
                <option value="0" {if $is_fictitious ==0} selected {/if} >请选择</option>
                <option value="1" {if $is_fictitious ==1} selected {/if}>真实</option>
                <option value="2" {if $is_fictitious ==2} selected {/if}>虚拟</option>
            </select>
        </div>
        <label class="col-xs-12 col-sm-1 control-label">时间选择</label>
        <div class="col-sm-2 col-xs-12">
            {php echo tpl_form_field_daterange('time', $time, false)}
        </div>
        <div class="col-xs-12 col-sm-2 col-md-2 col-lg-2">
            <button type="submit" class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
        </div>
    </div>
</form>
<div class="panel panel-default" >
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th style="width:60px;">id</th>
                <th style="width:60px;">昵称</th>
                <th style="width:80px;">头像</th>
                <th style="width:80px;">邀请人</th>
                <th style="width:80px;">余额<a href="{php echo $this->createWeburl('member', array('op' => 'money_sort'));}">↑</a><a href="{php echo $this->createWeburl('member', array('op' => 'money_r_sort'));}">↓</a></th>
                <th style="width:100px;">积分<a href="{php echo $this->createWeburl('member', array('op' => 'integral_sort'));}">↑</a><a href="{php echo $this->createWeburl('member', array('op' => 'integral_r_sort'));}">↓</a></th>
                <th style="width:100px;">电话号码</th>
                <th style="width:100px;">收款码</th>
                <th style="width:100px;">提现次数<a href="{php echo $this->createWeburl('member', array('op' => 'abnormal_sort'));}">↑</a><a href="{php echo $this->createWeburl('member', array('op' => 'abnormal_r_sort'));}">↓</a></th>
                <th style="width:100px;">邀请数量</th>
                <th style="width:100px;">道具数量</th>
                <th style="width:100px;">时间</th>
                <th style="width:100px;">操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $member['list'] $item}
            <tr>
                <td>{$item['id']}</td>
                <td>{$item['nickname']}</td>
                <td><img src="{php echo tomedia($item['headimgurl'])}" style="width: 60px; height: 30px;"></td>
                <td>{$item['inviter']}</td>
                <td>{$item['money']}</td>
                <td> {$item['integral']}</td>
                <td> {$item['phone']}</td>
                <td><a href="{php echo tomedia($item['payment_code'])}" target="_blank"><img src="{php echo tomedia($item['payment_code'])}" style="width: 60px; height: 30px;"></td>
                <td>{$item['cash']}</td>
                <td>{$item['inviteNumber']}</td>
                <td><a href="{php echo $this->createWeburl('memberCoupon', array('member_id' => $item['id']));}">{$item['couponCount']}</a></td>
                <td>{php echo date('Y-m-d H:i:s',$item['created'])}</td>
                <td>
             <!--       {if $item['is_block'] ==1}
                    <a href="javascript:;" data-id="{$item['id']}" class="block btn btn-success btn-sm">拉黑</a>
                    {else}
                    <a href="javascript:;" data-id="{$item['id']}" class="cancelBlock btn btn-warning btn-sm">取消拉黑</a>
                    {/if}-->
                <button class="btn btn-primary btn-sm changePhone" data-id="{$item['id']}" data-tid="{$item['nickname']}" data-toggle="modal" data-target="#myModal">修改手机号码</button>
                    <a href="javascript:;" id="{$item['id']}" class="delete btn btn-danger btn-sm">删除</a>
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
        {$member['pages']}
    </div>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        模态框（Modal）标题
                    </h4>
                </div>
                <div class="modal-body">
                    <input type="text"   name="phone" id="phone" value="" class="form-control">
                    <input type="hidden" name="id"  id="userId" value="" class="form-control">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary updatePhone">提交更改</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->

</div>
    <div class="ding" style="text-align: left; margin-left: 16px;"><span style="color:red;">点击收款码即可查看原图</span></div>
    <div class="ding" style="text-align: left; margin-left: 16px;">总计用户<span style="color: red">{php echo $total ? : 0}</span>,今日用户<span style="color: red">{php echo $todayMember ? : 0}</span></div>
{template 'footer'}

<script type="application/javascript">
    $(function () {
        $('.delete').click(function () {
            if (!confirm('确认要删除此用户?')) {
                return false;
            }
            id = $(this).attr('id');
            $.post('', {id:id, op:'delete'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });

        $('.block').click(function () {
            if (!confirm('确认要拉黑此用户?')) {
                return false;
            }
            id = $(this).data('id');
            $.post('', {id:id, op:'block'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('拉黑失败');
                }

            }, 'json')
        });


        $('.cancelBlock').click(function () {
            if (!confirm('确认要恢复此用户为正常状态?')) {
                return false;
            }
            id = $(this).data('id');
            $.post('', {id:id, op:'cancelBlock'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('恢复正常失败');
                }

            }, 'json')
        });


        $('.batch').click(function () {
            $.post('', {id:1,sort:1, op:'batch'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('添加失败');
                }

            }, 'json')
        });
        $('.updatePhone').click(function () {
            id = $("#userId").val();
            phone = $("#phone").val();
            if (!id) {
                alert('id不存在');
            }
            $.post('', {id:id,phone:phone, op:'updatePhone'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('修改失败');
                }
            }, 'json')
        });
        $('.settop').click(function () {
            id = $(this).data('id');
            $.post('', {id:id, op:'settop'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }
            }, 'json')
        });
        $('.changePhone').click(function () {
            id = $(this).data('id');
            name = $(this).data('tid');
            $("#myModalLabel").html('修改'+name + '的手机号码');
            $("#userId").val(id);

        })
    });

</script>